package com.framework.model.common;

import com.framework.common.annotation.QueryParam;
import com.framework.common.model.validation.ValidationGroup;
import com.framework.common.util.other.NumeralUtil;
import com.framework.model.base.BaseModel;

import javax.validation.constraints.Digits;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.math.BigDecimal;

/**
 * @author 龘鵺
 * @version 1.0
 * @className com.framework.model.common.Type
 * @title 公共类型类
 * @datetime 2024-04-20 14:57:12
 */
public class Type extends BaseModel implements Serializable {
    /**
     * 启用状态=1启用,2禁用 ENABLE_STATUS
     */
    @NotNull(message = "请选择启用状态", groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formAddItem.class, ValidationGroup.formEditItem.class})
    @Min(message = "启用状态错误", value = NumeralUtil.POSITIVE_ONE, groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formAddItem.class, ValidationGroup.formEditItem.class})
    @Max(message = "启用状态错误", value = Integer.MAX_VALUE, groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formAddItem.class, ValidationGroup.formEditItem.class})
    @QueryParam(name = "enableStatus", code = "p.ENABLE_STATUS")
    private Integer enableStatus;

    /**
     * 上级代码 PARENT_TYPE_CODE
     */
    @NotBlank(message = "请输入上级代码", groups = {ValidationGroup.formAddItem.class, ValidationGroup.formEditItem.class, ValidationGroup.formQueryItem.class})
    @Size(message = "上级代码最多128字符", max = 128, groups = {ValidationGroup.formAddItem.class, ValidationGroup.formEditItem.class, ValidationGroup.formQueryItem.class})
    @QueryParam(name = "parentTypeCode", code = "p.PARENT_TYPE_CODE")
    private String parentTypeCode;

    /**
     * 名称 TYPE_NAME
     */
    @NotBlank(message = "请输入名称", groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formAddItem.class, ValidationGroup.formEditItem.class})
    @Size(message = "名称最多256字符", max = 256, groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formAddItem.class, ValidationGroup.formEditItem.class})
    @QueryParam(name = "typeName", code = "p.TYPE_NAME")
    private String typeName;

    /**
     * 类型代码 TYPE_CODE
     */
    @NotBlank(message = "请输入类型代码", groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formAddItem.class, ValidationGroup.formEditItem.class})
    @Size(message = "类型代码最多128字符", max = 128, groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formAddItem.class, ValidationGroup.formEditItem.class})
    @QueryParam(name = "typeCode", code = "p.TYPE_CODE")
    private String typeCode;

    /**
     * 类型数值 TYPE_VALUE
     */
    @NotNull(message = "请选择类型数值", groups = {ValidationGroup.formAddItem.class, ValidationGroup.formEditItem.class})
    @Min(message = "类型数值错误", value = NumeralUtil.POSITIVE_ZERO, groups = {ValidationGroup.formAddItem.class, ValidationGroup.formEditItem.class})
    @Max(message = "类型数值错误", value = Integer.MAX_VALUE, groups = {ValidationGroup.formAddItem.class, ValidationGroup.formEditItem.class})
    @QueryParam(name = "typeValue", code = "p.TYPE_VALUE")
    private Integer typeValue;

    /**
     * 类型小数值 TYPE_DECIMAL
     */
    @NotNull(message = "请输入类型小数值", groups = {ValidationGroup.formAddItem.class, ValidationGroup.formEditItem.class})
    @Digits(message = "类型小数值最多12位数字或带有12位数字带4位小数", integer = 12, fraction = 4, groups = {ValidationGroup.formAddItem.class, ValidationGroup.formEditItem.class})
    @QueryParam(name = "typeDecimal", code = "p.TYPE_DECIMAL")
    private BigDecimal typeDecimal;

    /**
     * 描述 DESCRIPTION
     */
//    @NotBlank(message = "请输入描述", groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formAddItem.class, ValidationGroup.formEditItem.class})
    @Size(message = "描述最多2000字符", max = 2000, groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formAddItem.class, ValidationGroup.formEditItem.class})
    @QueryParam(name = "description", code = "p.DESCRIPTION")
    private String description;

    /**
     * t_type
     */
    private static final long serialVersionUID = 1L;

    public Integer getEnableStatus() {
        return enableStatus;
    }

    public void setEnableStatus(Integer enableStatus) {
        this.enableStatus = enableStatus;
    }

    public String getParentTypeCode() {
        return parentTypeCode;
    }

    public void setParentTypeCode(String parentTypeCode) {
        this.parentTypeCode = parentTypeCode == null ? null : parentTypeCode.trim();
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName == null ? null : typeName.trim();
    }

    public String getTypeCode() {
        return typeCode;
    }

    public void setTypeCode(String typeCode) {
        this.typeCode = typeCode == null ? null : typeCode.trim();
    }

    public Integer getTypeValue() {
        return typeValue;
    }

    public void setTypeValue(Integer typeValue) {
        this.typeValue = typeValue;
    }

    public BigDecimal getTypeDecimal() {
        return typeDecimal;
    }

    public void setTypeDecimal(BigDecimal typeDecimal) {
        this.typeDecimal = typeDecimal;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description == null ? null : description.trim();
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", enableStatus=").append(enableStatus);
        sb.append(", parentTypeCode=").append(parentTypeCode);
        sb.append(", typeName=").append(typeName);
        sb.append(", typeCode=").append(typeCode);
        sb.append(", typeValue=").append(typeValue);
        sb.append(", typeDecimal=").append(typeDecimal);
        sb.append(", description=").append(description);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Type other = (Type) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
                && (this.getCreateId() == null ? other.getCreateId() == null : this.getCreateId().equals(other.getCreateId()))
                && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
                && (this.getOperaterId() == null ? other.getOperaterId() == null : this.getOperaterId().equals(other.getOperaterId()))
                && (this.getOperaterTime() == null ? other.getOperaterTime() == null : this.getOperaterTime().equals(other.getOperaterTime()))
                && (this.getOperaterStatus() == null ? other.getOperaterStatus() == null : this.getOperaterStatus().equals(other.getOperaterStatus()))
                && (this.getEnableStatus() == null ? other.getEnableStatus() == null : this.getEnableStatus().equals(other.getEnableStatus()))
                && (this.getParentTypeCode() == null ? other.getParentTypeCode() == null : this.getParentTypeCode().equals(other.getParentTypeCode()))
                && (this.getTypeName() == null ? other.getTypeName() == null : this.getTypeName().equals(other.getTypeName()))
                && (this.getTypeCode() == null ? other.getTypeCode() == null : this.getTypeCode().equals(other.getTypeCode()))
                && (this.getTypeValue() == null ? other.getTypeValue() == null : this.getTypeValue().equals(other.getTypeValue()))
                && (this.getTypeDecimal() == null ? other.getTypeDecimal() == null : this.getTypeDecimal().equals(other.getTypeDecimal()))
                && (this.getDescription() == null ? other.getDescription() == null : this.getDescription().equals(other.getDescription()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getCreateId() == null) ? 0 : getCreateId().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getOperaterId() == null) ? 0 : getOperaterId().hashCode());
        result = prime * result + ((getOperaterTime() == null) ? 0 : getOperaterTime().hashCode());
        result = prime * result + ((getOperaterStatus() == null) ? 0 : getOperaterStatus().hashCode());
        result = prime * result + ((getEnableStatus() == null) ? 0 : getEnableStatus().hashCode());
        result = prime * result + ((getParentTypeCode() == null) ? 0 : getParentTypeCode().hashCode());
        result = prime * result + ((getTypeName() == null) ? 0 : getTypeName().hashCode());
        result = prime * result + ((getTypeCode() == null) ? 0 : getTypeCode().hashCode());
        result = prime * result + ((getTypeValue() == null) ? 0 : getTypeValue().hashCode());
        result = prime * result + ((getTypeDecimal() == null) ? 0 : getTypeDecimal().hashCode());
        result = prime * result + ((getDescription() == null) ? 0 : getDescription().hashCode());
        return result;
    }
}